//
//  RSMutableLineTextItem.m
//  iAccountBook
//
//  Created by 侯伟 on 2020/5/9.
//  Copyright © 2020 侯伟. All rights reserved.
//

#import "RSMutableLineTextItem.h"

@interface RSMutableLineTextItem ()

/// 标题
@property (nonatomic,weak)UILabel* titleLb;

/// 内容文本
@property (nonatomic,weak)UILabel* contentLb;

@end

@implementation RSMutableLineTextItem


+ (instancetype)itemWithTitle:(NSString *)title{
    return [self itemWithTitle:title isSingleLine:NO];
}

+ (instancetype)itemWithTitle:(NSString *)title isSingleLine:(BOOL)isSingleLine{
    RSMutableLineTextItem* cell = [RSMutableLineTextItem new];
    cell.title = title;
    cell.isSingleLine = isSingleLine;
    return cell;
}

- (instancetype)init{
    if(self = [super init]){
        self.myHeight = MyLayoutSize.wrap;
        self.myWidth = MyLayoutSize.wrap;
        
        [self initViews];
        
        [self initDatas];
    }
    return self;
}

- (void)initDatas{
    
    self.titleFont = FONT_FIT(12);
     
    self.titleColor = COLOR_GRAY_BASE;
    
    self.contentFont = FONT_FIT(12);
     
    self.contentColor = COLOR_GRAY_BASE;
    
    self.isSingleLine = NO;
}

- (void)initViews{
            
    UILabel* titleLb = [UILabel new];
    titleLb.textAlignment = NSTextAlignmentLeft;
    titleLb.myLeft = 0;
    titleLb.myTop = 0;
    titleLb.bottomPos.min(0);
    [self addSubview:titleLb];
    _titleLb = titleLb;
    
    UILabel* contentLb = [UILabel new];
    contentLb.textAlignment = NSTextAlignmentLeft;
    contentLb.numberOfLines = 0;
    contentLb.myHeight = MyLayoutSize.wrap;
    contentLb.myWidth = MyLayoutSize.wrap;
    contentLb.myVertMargin = 0;
    contentLb.myRight = 0;
    contentLb.leftPos.equalTo(titleLb.rightPos);
    [self addSubview:contentLb];
    _contentLb = contentLb;
}

#pragma mark --setter


- (void)setTitle:(NSString *)title{
    _title = title;
    self.titleLb.text = title;
    [self.titleLb sizeToFit];
}

- (void)setAttributedTitle:(NSAttributedString *)attributedTitle{
    _attributedTitle = attributedTitle;
    self.titleLb.attributedText = attributedTitle;
    [self.titleLb sizeToFit];
}

- (void)setTitleFont:(UIFont *)titleFont{
    _titleFont = titleFont;
    self.titleLb.font = titleFont;
    [self.titleLb sizeToFit];
}

- (void)setTitleColor:(UIColor *)titleColor{
    _titleColor = titleColor;
    self.titleLb.textColor = titleColor;
}

- (void)setContent:(NSString *)content{
    _content = content;
    self.contentLb.text = content;
    [self.contentLb sizeToFit];
}


- (void)setAttributedContent:(NSAttributedString *)attributedContent{
    _attributedContent = attributedContent;
    self.contentLb.attributedText = attributedContent;
    [self.contentLb sizeToFit];
}

- (void)setContentFont:(UIFont *)contentFont{
    _contentFont = contentFont;
    self.contentLb.font = contentFont;
    [self.contentLb sizeToFit];
}

- (void)setContentColor:(UIColor *)contentColor{
    _contentColor = contentColor;
    self.contentLb.textColor = contentColor;
}

-(void)setIsSingleLine:(BOOL)isSingleLine{
    _isSingleLine = isSingleLine;
    self.contentLb.numberOfLines = isSingleLine?1:0;
}
@end
